//
//  LGRecordHeaderView.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/2/28.
//

#import "LGSportRecordHeaderView.h"

#define lineWidth  (Screen_W-viewPix(32)-viewPix(132)-viewPix(12))

@interface LGSportRecordHeaderView()
/**   */
@property (nonatomic , strong)UILabel *trainDayLabel;
/**   */
@property (nonatomic , strong)UILabel *trainTimeLabel;

@end

@implementation LGSportRecordHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setTrainDays:(NSString *)trainDays{
    _trainDays = trainDays;
    self.trainDayLabel.text = trainDays;
}

-(void)setTrainTimes:(NSString *)trainTimes{
    _trainTimes = trainTimes;
    self.trainTimeLabel.text = trainTimes;
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.backgroundColor = [UIColor colorWithString:@"#F3F7F8"];
    UIView *baseView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_W, viewPix(102))];
    baseView.backgroundColor = [UIColor whiteColor];
    CGFloat itemW = (Screen_W-viewPix(48))/2.0;
    UIView *daysView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(18), viewPix(10), itemW, viewPix(78))];
    daysView.backgroundColor = [UIColor colorWithString:@"#F4F9FA"];
    daysView.cornerRidus = 7;
    [baseView addSubview:daysView];
    UIButton *daysButton = [UIButton buttonWithTitle:@" 已训练" titleFont:LGFont(14) textColor:@"#606266" imageName:@"运动记录-已训练"];
    daysButton.frame = CGRectMake(viewPix(11), viewPix(11), viewPix(100), viewPix(20));
    daysButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    daysButton.userInteractionEnabled = NO;
    [daysView addSubview:daysButton];
    [daysView addSubview:self.trainDayLabel];
    UILabel *daysUnitLabel = [UILabel lableWithText:@"天" colorString:@"#909399" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [daysView addSubview:daysUnitLabel];
    [self.trainDayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(daysView).offset(viewPix(11));
        make.top.equalTo(daysButton.mas_bottom).offset(viewPix(5));
    }];
    [daysUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.trainDayLabel.mas_right).offset(viewPix(5));
        make.bottom.equalTo(self.trainDayLabel);
    }];
    
    UIView *timesView = [[UIView alloc]initWithFrame:CGRectMake(kMaxX(daysView.frame)+viewPix(12), viewPix(10), itemW, viewPix(78))];
    timesView.backgroundColor = [UIColor colorWithString:@"#F4F9FA"];
    timesView.cornerRidus = 7;
    [baseView addSubview:timesView];
    UIButton *timesButton = [UIButton buttonWithTitle:@" 运动时长" titleFont:LGFont(14) textColor:@"#606266" imageName:@"运动记录-运动时长"];
    timesButton.frame = CGRectMake(viewPix(11), viewPix(11), viewPix(100), viewPix(20));
    timesButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    timesButton.userInteractionEnabled = NO;
    [timesView addSubview:timesButton];
    [timesView addSubview:self.trainTimeLabel];
    UILabel *timesUnitLabel = [UILabel lableWithText:@"小时" colorString:@"#909399" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [timesView addSubview:timesUnitLabel];
    [self.trainTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(timesView).offset(viewPix(11));
        make.top.equalTo(timesButton.mas_bottom).offset(viewPix(5));
    }];
    [timesUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.trainTimeLabel.mas_right).offset(viewPix(5));
        make.bottom.equalTo(self.trainTimeLabel);
    }];
    [self addSubview:baseView];
    
}


-(UILabel *)trainDayLabel{
    if(!_trainDayLabel){
        _trainDayLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(24, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _trainDayLabel;
}


-(UILabel *)trainTimeLabel{
    if(!_trainTimeLabel){
        _trainTimeLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(24, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _trainTimeLabel;
}




@end
